package com.huawei.lynnbit.tool.cocos.processor.leaf;

import com.huawei.lynnbit.tool.cocos.config.game.GameConfig;
import com.huawei.lynnbit.tool.cocos.config.game.task.CmdTask;
import com.huawei.lynnbit.tool.cocos.config.game.task.Task;
import com.huawei.lynnbit.tool.cocos.util.CmdUtils;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

@Slf4j
public class CmdProcessor extends LeafProcessor {
    public CmdProcessor(Task task, GameConfig gameConfig) {
        this.task = task;
        this.gameConfig = gameConfig;
    }

    @Override
    public void doProcess() throws IOException, InterruptedException {
        if (Task.TYPE_CMD.equals(task.getType())) {
            CmdTask taskInfo = (CmdTask) this.task;
            CmdUtils.exec(taskInfo.getRunDir(), taskInfo.getRunCmd().split(" "));
        }
    }
}
